package com.zhentao.websocket.pojo;


/**
 * 用来封装服务端给浏览器发送的消息数据
 * 支持私聊和群聊消息
 */

public class ResultMessage {

    private boolean isSystem;
    private Integer fromId;
    private Integer toId; // 接收者ID
    private String fromName;
    private Object message;// 如果是系统消息是数组
    private String messageType = "text"; // 消息类型：text, image, voice, video, file
    private String chatType = "private"; // 聊天类型：private(私聊), group(群聊)
    private Long groupId; // 群组ID（群聊时使用）

    // 图片消息相关字段
    private String imageUrl; // 图片URL（当messageType为image时使用）
    private Long fileSize; // 文件大小（字节）
    private String originalFilename; // 原始文件名

    // 视频消息相关字段
    private String videoUrl; // 视频URL（当messageType为video时使用）
    private String videoCoverUrl; // 视频封面图URL
    private Long videoDuration; // 视频时长（秒）
    private Integer videoWidth; // 视频宽度
    private Integer videoHeight; // 视频高度

    // 头像信息字段
    private String fromAvatar; // 发送方头像URL
    private String toAvatar; // 接收方头像URL

    public ResultMessage() {

    }

    public ResultMessage(boolean isSystem, String fromName, Object message) {
        this.isSystem = isSystem;
        this.fromName = fromName;
        this.message = message;
    }

    public ResultMessage(boolean isSystem, String fromName, Object message, String chatType, Long groupId) {
        this.isSystem = isSystem;
        this.fromName = fromName;
        this.message = message;
        this.chatType = chatType;
        this.groupId = groupId;
    }

    public ResultMessage(boolean isSystem, String fromName, Object message, String messageType, String chatType, Long groupId) {
        this.isSystem = isSystem;
        this.fromName = fromName;
        this.message = message;
        this.messageType = messageType;
        this.chatType = chatType;
        this.groupId = groupId;
    }

    public void setFromId(Integer fromId) {
        this.fromId = fromId;
    }

    public Integer getFromId() {
        return fromId;
    }

    public void setToId(Integer toId) {
        this.toId = toId;
    }

    public Integer getToId() {
        return toId;
    }

    public boolean isSystem() {
        return isSystem;
    }

    public void setSystem(boolean system) {
        isSystem = system;
    }

    public String getFromName() {
        return fromName;
    }

    public void setFromName(String fromName) {
        this.fromName = fromName;
    }

    public Object getMessage() {
        return message;
    }

    public void setMessage(Object message) {
        this.message = message;
    }

    public String getChatType() {
        return chatType;
    }

    public void setChatType(String chatType) {
        this.chatType = chatType;
    }

    public String getMessageType() {
        return messageType;
    }

    public void setMessageType(String messageType) {
        this.messageType = messageType;
    }

    public Long getGroupId() {
        return groupId;
    }

    public void setGroupId(Long groupId) {
        this.groupId = groupId;
    }

    // 图片消息相关字段的getter和setter
    public String getImageUrl() {
        return imageUrl;
    }

    public void setImageUrl(String imageUrl) {
        this.imageUrl = imageUrl;
    }

    public Long getFileSize() {
        return fileSize;
    }

    public void setFileSize(Long fileSize) {
        this.fileSize = fileSize;
    }

    public String getOriginalFilename() {
        return originalFilename;
    }

    public void setOriginalFilename(String originalFilename) {
        this.originalFilename = originalFilename;
    }

    // 视频消息相关字段的getter和setter
    public String getVideoUrl() {
        return videoUrl;
    }

    public void setVideoUrl(String videoUrl) {
        this.videoUrl = videoUrl;
    }

    public String getVideoCoverUrl() {
        return videoCoverUrl;
    }

    public void setVideoCoverUrl(String videoCoverUrl) {
        this.videoCoverUrl = videoCoverUrl;
    }

    public Long getVideoDuration() {
        return videoDuration;
    }

    public void setVideoDuration(Long videoDuration) {
        this.videoDuration = videoDuration;
    }

    public Integer getVideoWidth() {
        return videoWidth;
    }

    public void setVideoWidth(Integer videoWidth) {
        this.videoWidth = videoWidth;
    }

    public Integer getVideoHeight() {
        return videoHeight;
    }

    public void setVideoHeight(Integer videoHeight) {
        this.videoHeight = videoHeight;
    }

    // 头像信息字段的getter和setter
    public String getFromAvatar() {
        return fromAvatar;
    }

    public void setFromAvatar(String fromAvatar) {
        this.fromAvatar = fromAvatar;
    }

    public String getToAvatar() {
        return toAvatar;
    }

    public void setToAvatar(String toAvatar) {
        this.toAvatar = toAvatar;
    }

    @Override
    public String toString() {
        return "ResultMessage{" +
                "isSystem=" + isSystem +
                ", fromId=" + fromId +
                ", toId=" + toId +
                ", fromName='" + fromName + '\'' +
                ", message=" + message +
                ", messageType='" + messageType + '\'' +
                ", chatType='" + chatType + '\'' +
                ", groupId=" + groupId +
                ", imageUrl='" + imageUrl + '\'' +
                ", fileSize=" + fileSize +
                ", originalFilename='" + originalFilename + '\'' +
                ", videoUrl='" + videoUrl + '\'' +
                ", videoCoverUrl='" + videoCoverUrl + '\'' +
                ", videoDuration=" + videoDuration +
                ", videoWidth=" + videoWidth +
                ", videoHeight=" + videoHeight +
                ", fromAvatar='" + fromAvatar + '\'' +
                ", toAvatar='" + toAvatar + '\'' +
                '}';
    }

}
